<template>
  <!-- 过渡动画 -->
  <transition name="fade">
    <div class="img-view" @click="bigImg">
      <!-- 遮罩层 -->
      <div class="img-layer"></div>
      <div class="zoomImg">
        <img :src="imgSrc">
      </div>
    </div>
  </transition>
</template>
<script>
  export default {
    props: ['imgSrc'],
    data () {
      return {

      }
    },
    methods: {
      bigImg() {
        // 发送事件
        this.$emit('clickit')
      }
    }
  }
</script>
<style scoped>
  /*动画*/
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 0s
    /*transition: all .2s linear;*/
    /*transform: translate3D(0, 0, 0);*/
  }

  .fade-enter,
  .fade-leave-active {
    opacity: 0;
    /*transform: translate3D(100%, 0, 0);*/
  }


  /* bigimg */

  .img-view {
    position: relative;
    width: 100%;
    height: 100%;
  }

  /*遮罩层样式*/
  .img-view .img-layer {
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    bottom:0;
    right:0;
    background: rgba(0, 0, 0, 0.7);
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /*不限制图片大小，实现居中*/
  .img-view .zoomImg img {
    max-width: 90%;
    max-height:90%;
    margin:auto;
    display: block;
    position: fixed;
    left:0;
    right:0;
    bottom:0;
    top:0;
    z-index: 900000;
  }
</style>
